import Vue from 'vue';
import VueRouter from 'vue-router';

// 组件的懒加载
const Home = () => import('views/home/Home')
const Category = () => import('views/category/Category')
const Carts = () => import('views/carts/Carts')
const Profile = () => import('views/profile/Profile')
const Details = () => import('views/details/Details')

// 使用
Vue.use(VueRouter)

// 创建路由对象
const routes = [{
	path: "",
	redirect: '/home'
}, {
	name:"category",
	path: "/category",
	component: Category,
	meta:{
		tabbarShow:true,
	}
}, {
	name:"carts",
	path: "/carts",
	component: Carts,
	meta:{
		tabbarShow:true,
	}
}, {
	name:"profile",
	path: "/profile",
	component: Profile,
	meta:{
		tabbarShow:true,
	}
}, {
	name:"home",
	path: "/home",
	component: Home,
	meta:{
		tabbarShow:true,
	}
},{
	name:"details",
	path: "/details/:iid",
	component: Details,
	meta:{
		tabbarShow:false,
	}
}]
const router = new VueRouter({
	routes,
	mode: 'history'
})
// 解决 Vue 重复点击相同路由，出现 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation 问题
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
	return VueRouterPush.call(this, to).catch(err => err)
}
// 导出路由

export default router
